package com.cn.wanxi.servlet;

import com.cn.wanxi.model.NewsModel;
import com.cn.wanxi.service.NewsService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/home")
public class HomeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


//        CompanyService companyService = new CompanyService();
//        CompanyModel companyModel = companyService.getCompanyModel();
//
//        NavService navService = new NavService();
//        NavModel[] navModels = navService.getNavModels();
//        req.setAttribute("navModels", navModels);
//        req.setAttribute("companyModel", companyModel);

        CommonServlet.setCompanyAndNavData(req);
//        新闻数据
        NewsService newsService = new NewsService();
        NewsModel[] newsModels = newsService.getNewsModelForHomePage();
        req.setAttribute("newsModels",newsModels);
        req.getRequestDispatcher("/jsp/home.jsp").forward(req, resp);
    }
}


